<?php
defined('PT_ACCESS') or die('No direct access');

class users extends ActionController{

	public $model;

	public function __construct(){
		global $registry, $language;

		$this->model = new userModel($registry);

		$this->viewData = array(
				'pageTitle'=>$language->get('page_login_title'),
				'pageFooter'=>$language->get('pageFooter')
		);
	}

	public function __destruct(){
		unset($this->viewData);
	}

	public function indexAction(){
		global $language;
		$this->viewData = array(
				'pageTitle'=>$language->get('page_login_title'),
				'pageFooter'=>$language->get('pageFooter')
		);
	}

	public function loginAction(){
		global $language;

		$msg = $this->model->login('/PTadmin');

		$this->viewData = array(
				'pageMsg'=>$msg,
				'pageAction'=>BASE_URL . '/' . ADMIN . '/?page=user&action=login',
				'pageTitle'=>$language->get('page_login_title'),
				'pageFooter'=>$language->get('pageFooter')
		);
	}

	public function logoutAction(){
		$this->model->logout('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
	}
}
